<%--                                                                       --%>
<%-- Copyright (c) 2001-2003 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries.                       --%>
<%--                                                                       --%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/bv-html.tld" prefix="bvhtml" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>

<jsp:useBean id="folderItems" type="java.util.Collection" scope="request" />

<script language="JavaScript">

function confirmDeleteFolder() {
  if ( confirm('<bean:message key="cs.confirm.delete.folder"/>')) {
    return true;
  } else {
    return false;
  }
}        

function confirmDeleteDocument() {
  if ( confirm('<bean:message key="cs.confirm.delete.document"/>')) {
    return true;
  } else {
    return false;
  }
}        

function onClickSwitchPhase(theForm) {
  theForm.displayPhaseId.value = theForm.elements['urlParams.displayPhaseId'].value;
  theForm.submit();
}

</script>

<!-- BEGIN Document Index -->
  
<!-- Zone 5 starts here.  -->
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" 
       summary="content area">
  <tr>
    <td valign="top">
    
    <!--start microsite logo and name here-->
    <div class="pageTitle">
      <%@ include file="/cs/microsite/micrositeNaviInfo.jsp" %>
    </div> 
    <!--end microsite logo and name here-->

    <!--  BEGIN form { switch phase } ----------------------------- -->
    <div class="generalWrapRight">
      <logic:equal name="micrositeNaviInfoView" property="micrositeTemplatePhaseFlag" value="true">
      <html:form action="/cs/documentIndex.do" method="post">

          <!-- Note that "All Phases" is not an option for documents -->
          <bvhtml:hiddenList name="micrositeNaviInfoView" property="urlParams" scope="request"/>
          <html:select name="micrositeNaviInfoView" property="urlParams.displayPhaseId" size="1">  
            <bean:define id="allPhasesList" name="documentListView" property="allPhasesList" />
            <html:optionsCollection name="documentListView" property="allPhasesList"/>
          </html:select>&nbsp;    
      
          <input type="button" class="titleButton" 
                 onclick="onClickSwitchPhase(this.form)"
                 value="<bean:message key='button.go'/>" 
                 titleKey="button.go">
        </html:form>
      </logic:equal>
    </div> 
    <!--  END form { switch phase } ----------------------------- -->  
      
    <!--start title bar here-->
    <div class="pageSubtitle">
      <!-- Documents index title -->
      <span class="left">
        <logic:equal name="documentListView" property="rootFolder" value="true">
          <bean:message key="cs.document.index"/>       
        </logic:equal>
        <logic:notEqual name="documentListView" property="rootFolder" value="true">
          <bean:write name="documentListView" property="folderName"/> &nbsp;<bean:message key="cs.folder"/>
        </logic:notEqual>        
      </span>
      <logic:notEqual name="documentListView" property="isReadOnly" value="true">
        <%-- Dummy form to make the buttons legal HTML --%>
        <form action="#" onsubmit="return false">
          <span class="right">
            <!-- Create new folder button -->
            <logic:equal name="documentListView" property="folderCreator" value="true">        
              <input type="submit" class="titleButton" value="<bean:message key="button.new.folder"/>" onclick="location='<html:rewrite page="/cs/folderEdit.do" name="micrositeNaviInfoView" property="urlParams" scope="request"/>'"/>
            </logic:equal>       
            <!-- Create new document button -->  
            <logic:equal name="documentListView" property="publisher" value="true">      
              <input type="submit" class="titleButton" value="<bean:message key="button.new.document"/>" onclick="location='<html:rewrite page="/cs/documentNew.do" name="micrositeNaviInfoView" property="urlParams" scope="request"/>'"/>
            </logic:equal>
          </span>
        </form>
      </logic:notEqual>
    </div> 
    <!--end title bar here-->

    <div class="blockWrap">

    <!-- Start list of folders and documents here -->
    <table class="dataTable" border="0" cellspacing="1" cellpadding="2" 
           summary="Search result table" width="100%">
      <tr class="listHeader"> 
        <th id="Name" align="left"><bean:message key="cs.name"/></th>
        <th id="Description" align="left"><bean:message key="cs.description"/></th>
        <th id="LastModTime" align="left"><bean:message key="cs.last.mod.date"/></th>
        <th id="Action" align="left"><bean:message key="cs.actions"/></th>
      </tr>

      <!--start folder list here-->
      <logic:iterate id="oneFolder" name="folderItems" indexId="index">
        <tr class='<%=index.intValue() % 2 == 0 ? "listEven" : "listOdd"%>'> 
          <td headers="Name">
            <html:img page="/cs/images/buttons/global/gbtn_folder.gif" width="22" height="18" align="absmiddle" altKey="cs.folder" border="0"/>
            <html:link page="/cs/documentIndex.do" name="oneFolder" property="folderUrlParams">
            <bean:write name="oneFolder" property="name" /></html:link>
          </td>
    
          <td headers="Description">
            <bean:write name="oneFolder" property="description" />
          </td>

          <td headers="LastModTime">
<bean:write name="oneFolder" property="lastModTime" formatKey="format.datetime.long"/>
          </td>

          <td headers="Action" nowrap align="left">
            <%-- Display Edit and Delete button --%>
            <logic:notEqual name="oneFolder" property="isReadOnly" value="true">
              <logic:equal name="oneFolder" property="editor" value="true" >
                <%-- Only folder's owner can edit/delete the folder. --%>
                <html:link page="/cs/folderEdit.do" name="oneFolder" property="urlParams">         
                  <html:img page="/cs/images/action/icon_edit.gif" styleClass="actionIcon" border="0" altKey="cs.image.alt.edit"/>
                </html:link> 
                <html:link page="/cs/folderDelete.do" name="oneFolder" property="urlParams" onclick="return confirmDeleteFolder();">
                  <html:img page="/cs/images/action/icon_delete.gif" styleClass="actionIcon" border="0" altKey="cs.image.alt.delete"/>
                </html:link>
              </logic:equal>
            </logic:notEqual>
          </td>
        </tr>
      </logic:iterate>
      <!--end folder list here-->

      <!--start document list here-->
      <logic:iterate id="oneDoc" name="documentItems" indexId="index">
        <tr class='<%=(index.intValue() + folderItems.size()) % 2 == 0 ? "listEven" : "listOdd"%>'> 
          <td headers="Name">
            <html:img page="/cs/images/buttons/global/gbtn_document.gif" width="22" height="18" align="absmiddle" altKey="cs.document" border="0"/>
            <html:link page="/cs/documentView.do" name="oneDoc" property="urlParams">
            <bean:write name="oneDoc" property="name" /></html:link>
          </td>
    
          <td headers="Description">
            <bean:write name="oneDoc" property="description" />
          </td>

          <td headers="LastModTime">
<bean:write name="oneDoc" property="lastModTime" formatKey="format.datetime.long"/>
          </td>

          <td headers="Action" nowrap align="left">
            <%-- Display Edit and Delete button --%>
            <logic:notEqual name="oneDoc" property="isReadOnly" value="true">
              <logic:equal name="oneDoc" property="editor" value="true" >
                <%-- Only document's owner can edit/delete the document. --%>
                <html:link page="/cs/documentEdit.do" name="oneDoc" property="urlParams">
                  <html:img page="/cs/images/action/icon_edit.gif" styleClass="actionIcon" border="0" altKey="cs.image.alt.edit"/>
                </html:link> 
                <html:link page="/cs/documentDelete.do" name="oneDoc" property="urlParams" onclick="return confirmDeleteDocument();">
                  <html:img page="/cs/images/action/icon_delete.gif" styleClass="actionIcon" border="0" altKey="cs.image.alt.delete"/>
                </html:link>
              </logic:equal>
            </logic:notEqual>
          </td>
        </tr>
      </logic:iterate>
      <c:choose>
      	<c:when test="${empty folderItems && empty documentItems}">
		<tr class="listOdd">
		<td colspan="4" align="center">
		<bean:message key="cs.collaboration.noFolders"/>
		</td
		</tr>
	</c:when>
       </c:choose>
      <!--end document list here-->
  
    </table>
    <!-- End list of folders and documents here -->
    </div>
    </td>
  </tr>
</table>
<!--end zone 5 content here -->     
